<template>
  <div>
    <el-tree
      :data="list"
      :props="defaultProps"
      @node-click="handleNodeClick"
    ></el-tree>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "treecompany",
  data() {
    return {
      list: [
        {
          name: this.name,
          son: [
            {
              name: this.name,
              children: [
                {
                  name: this.name,
                },
              ],
            },
          ],
        },
      ],
      defaultProps: {
        children: "son",
        label: "name",
      },
    };
  },
  methods: {
    handleNodeClick(data) {
      console.log(data.id);
      this.$emit("changepid", data.id);
    },
    gettree() {
      axios({ url: "treecom", method: "get" }).then((res) => {
        this.list = res.data.list;
      });
    },
  },
  mounted() {
    this.gettree();
  },
};
</script>

<style scoped></style>
